package com.hotel.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("token-service", r -> r.path("/api/token/**").uri("lb://hotel-auth-service"))
                .route("user-service", r -> r.path("/api/users/**", "/api/roles/**", "/api/permissions/**", 
                                                     "/api/hotels/**", "/api/rooms/**", "/api/auth/**")
                        .uri("lb://hotel-user-service"))
                .route("order-service", r -> r.path("/api/orders/**", "/order/**").uri("lb://hotel-order-service"))
                .route("payment-service", r -> r.path("/api/payments/**").uri("lb://hotel-payment-service"))
                .build();
    }
}